<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/mui.css"/>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/general.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/lcs-font.css"/>
		<style type="text/css">
			.main{
				background-color: white;
			}
			.mui-input-row>.longtext{
				width: 60%;
			}
			.mui-input-row>input{
				width: 40% !important;
			}
			.selectdiv{
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.selectdiv>label{
				font-family: 'Helvetica Neue',Helvetica,sans-serif;
			    line-height: 1.1;
			    float: left;
			    width: 60%;
			    padding: 11px 15px;
			}
			
			.place button{
				width:100%;
				color: #676664 !important;
			    border: 0 !important;
			 	text-align: right;
			 	height: 100%;
			}
			.place{
			    width: 40%;
			    height: 100%;
			}
			.mui-input-row label {
    font-family: 'Helvetica Neue',Helvetica,sans-serif;
    line-height: 1.1;
    float: left;
    width: 60%;
    padding: 11px 15px;
}
.input-row{
	display: flex;
	align-content: center;
	justify-content: flex-start;
}
.input-row>.leftdiv{
	width: 40%;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	padding: 11px 15px;
}
.input-row>input{
	width: 60%;
	line-height: 21px;
	height: 40px;
    margin-bottom: 0;
    padding: 11px 15px;
    border: 0;
    text-align: left;
}
.lcs-row{
	display: flex;
	align-content: center;
	justify-content: flex-start;
}
.lcs-row>.leftdiv{
	width: 40%;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	padding: 11px 15px;
}
.lcs-row>input{
	width: 30%;
	line-height: 21px;
	height: 40px;
    margin-bottom: 0;
    padding: 11px 15px;
    border: 0;
    text-align: center;
}
.lcs-row>.rightdiv{
	width: 30%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 11px 15px;
}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">参数设置</h1>
		    <div class="ic mui-icon-right-nav mui-pull-right" id="goadd">保存</div>
		</header>
		<div class="mui-content">
		    <div class="main" id="mainid">
		    	
		    	  <div class="input-row border-b">
			        <div class="leftdiv">会员初始密码</div>
			        <input id="init_password" type="text" class="textr" value="888888">
			    </div>
		    	<!--
                	作者：592176224@qq.com
                	时间：2019-04-29
                	描述：
			    <div class="mui-input-row border-b">
			        <label class="fe09">会员初始密码</label>
			        <input id="init_password" type="text" class="textr" value="888888">
			    </div>
                -->
			    <div class="mui-input-row border-b">
			        <label class="longtext fe09">结算金额四舍五入</label>
			        <div class="mui-switch mui-switch-blue" id="round_up">
			            <div class="mui-switch-handle"></div>
			        </div>
			    </div>
			    <div class="mui-input-row border-b">
			        <label class="longtext fe09">会员是否支持跨店消费</label>
			        <div class="mui-switch mui-switch-blue" id="cross_shop">
			            <div class="mui-switch-handle"></div>
			        </div>
			    </div>
			    <div class="mui-input-row border-b">
			        <label class="longtext fe09">提成是否支持开单时修改</label>
			        <div class="mui-switch mui-switch-blue" id="edit_percent">
			            <div class="mui-switch-handle"></div>
			        </div>
			    </div>
			    <div class="mui-input-row border-b">
			        <label class="longtext fe09">收银开单单价可修改</label>
			        <div class="mui-switch mui-switch-blue" id="edit_price">
			            <div class="mui-switch-handle"></div>
			        </div>
			    </div>
			    <div class="mui-input-row border-b">
			        <label class="longtext fe09">允许零库存出库</label>
			        <div class="mui-switch mui-switch-blue" id="zero_stock_out">
			            <div class="mui-switch-handle"></div>
			        </div>
			    </div>
			    
			    <div class="lcs-row border-b">
			        <div class="leftdiv">顾客生日提前</div>
			        <input id="member_birthday" type="number" value="3">
			        <div class="rightdiv">天提前 </div>
			    </div>
		    	<div class="lcs-row border-b">
			        <div class="leftdiv">会员余额低过</div>
			        <input id="member_money_low" type="number" value="100">
			        <div class="rightdiv">元提醒 </div>
			    </div>
			    
		    	<div class="lcs-row border-b">
			        <div class="leftdiv">顾客未到店</div>
			        <input id="non_arrival" type="number" value="30">
			        <div class="rightdiv">天提醒 </div>
			    </div>
			    
			    <div class="lcs-row border-b">
			        <div class="leftdiv">顾客欠款</div>
			        <input id="arrears" type="number" value="100">
			        <div class="rightdiv">元提醒 </div>
			    </div>
			    <!--
                	作者：592176224@qq.com
                	时间：2019-04-29
                	描述：
			    <div class="lcs-row border-b">
			        <div class="leftdiv">会员卡到期前</div>
			        <input id="card_expire" type="number" value="7">
			        <div class="rightdiv">天提醒 </div>
			    </div>
                -->
			    <div class="lcs-row border-b">
			        <div class="leftdiv">卡项到期前</div>
			        <input id="service_expire" type="number" value="7">
			        <div class="rightdiv">天提醒 </div>
			    </div>
			    <div class="lcs-row border-b">
			        <div class="leftdiv">次卡不足</div>
			        <input id="time_card" type="number" value="1">
			        <div class="rightdiv">次提醒 </div>
			    </div>
			    
			  	<div class="lcs-row border-b">
			        <div class="leftdiv">库存不足</div>
			        <input id="low_stock" type="number" value="2">
			        <div class="rightdiv">个提醒 </div>
			    </div>
<!--			    
			    <div class="mui-input-row border-b">
			        <label class="fe09">顾客生日提前？天</label>
			        <input id="member_birthday" type="text" class="textr" value="3">
			    </div>
			  
			    <div class="mui-input-row border-b">
			        <label class="fe09">会员余额低过？元提醒</label>
			        <input id="member_money_low" type="text" class="textr" value="100">
			    </div>
			   <div class="mui-input-row border-b">
			        <label class="fe09">久未到店？天提醒</label>
			        <input id="non_arrival" type="text" class="textr" value="30">
			    </div>
			    <div class="mui-input-row border-b">
			        <label class="fe09">顾客欠款？天提醒</label>
			        <input id="arrears" type="text" class="textr" value="100">
			    </div>
			    <div class="mui-input-row border-b">
			        <label class="fe09">会员卡到期？天提醒</label>
			        <input id="card_expire" type="text" class="textr" value="7">
			    </div>
			   <div class="mui-input-row border-b">
			        <label class="fe09">服务项目到期？天提醒</label>
			        <input id="service_expire" type="text" class="textr" value="7">
			    </div>
			   <div class="mui-input-row border-b">
			        <label class="fe09">次卡不足？次提醒</label>
			        <input id="time_card" type="text" class="textr" value="1">
			    </div>
			    <div class="mui-input-row border-b">
			        <label class="fe09">库存不足低过？个提醒</label>
			        <input id="low_stock" type="text" class="textr" value="2">
			    </div>-->
			    
			    <div class="mui-input-row border-b">
			        <label class="longtext fe09">会员消费是否积分</label>
			        <div class="mui-switch mui-switch-blue" id="is_support">
			            <div class="mui-switch-handle"></div>
			        </div>
			    </div>
			    
			    <div class="lcs-row border-b">
			        <div class="leftdiv">消费</div>
			        <input id="many_cost" type="number" value="1">
			        <div class="rightdiv">元,积一分 </div>
			    </div>
		    	<div class="lcs-row border-b">
			        <div class="leftdiv">充值</div>
			        <input id="many_recharge" type="number" value="1">
			        <div class="rightdiv">元,积一分 </div>
			    </div>
			    <!--<div class="mui-input-row border-b">
			        <label class="fe09">消费？元，积一分</label>
			        <input id="many_cost" type="text" class="textr" value="1">
			    </div>
			    <div class="mui-input-row border-b">
			        <label class="fe09">充值？元，积一分</label>
			        <input id="many_recharge" type="text" class="textr" value="1">
			    </div>-->
			   
			    <div class="mui-input-row border-b">
			        <label class="longtext fe09">推荐会员是否积分</label>
			        <div class="mui-switch mui-switch-blue" id="is_recommend">
			            <div class="mui-switch-handle"></div>
			        </div>
			    </div>
			    
			    <div class="lcs-row border-b">
			        <div class="leftdiv">推荐会员，积</div>
			        <input id="many_recommend" type="number" value="1">
			        <div class="rightdiv">分 </div>
			    </div>
			   	<!--<div class="mui-input-row border-b">
			        <label class="fe09">推荐一名会员？积分</label>
			        <input id="many_recommend" type="text" class="textr" value="1">
			    </div>-->
			    <div class="mui-input-row border-b">
			        <label class="longtext fe09">被推荐人同时积分</label>
			        <div class="mui-switch mui-switch-blue" id="member_recommend">
			            <div class="mui-switch-handle"></div>
			        </div>
			    </div>
			    <!--
                	作者：592176224@qq.com
                	时间：2019-04-29
                	描述：
			    <div class="mui-input-row border-b">
			        <label class="fe09">推荐积分比例</label>
			        <input id="recommend_score_percent" type="number" class="textr" value="0" placeholder="0-100">
			    </div>
                -->
			    <div class="lcs-row border-b">
			        <div class="leftdiv">推荐积分比例</div>
			        <input id="recommend_score_percent" type="number" class="textr" value="0" placeholder="0-100">
			        <div class="rightdiv"></div>
			    </div>
		    </div>
		    
		</div>
		<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/mui.picker.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.poppicker.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/city.data.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var pdi = 0; 	//配置id
			window.onload = function(){
				mui.init();
				getsetdetail();
				
				
				//保存修改
				g("goadd").addEventListener("tap",function(e){
					var round_up = g("round_up").classList.contains("mui-active");
					var cross_shop = g("cross_shop").classList.contains("mui-active");
					var edit_percent = g("edit_percent").classList.contains("mui-active");
					var edit_price = g("edit_price").classList.contains("mui-active");
					var is_support = g("is_support").classList.contains("mui-active");
					var is_recommend = g("is_recommend").classList.contains("mui-active");
					var member_recommend = g("member_recommend").classList.contains("mui-active");
					var zero_stock_out = g("zero_stock_out").classList.contains("mui-active");
					var data = {
						url:"/api/set/edit",
						data:{
							access_token:acctoken(),
							id:pid,
							init_password:g("init_password").value,
							round_up:round_up?1:2,
							cross_shop:cross_shop?1:2,
							edit_percent:edit_percent?1:2,
							edit_price:edit_price?1:2,
							zero_stock_out:zero_stock_out?1:2,
							member_birthday:g("member_birthday").value,
							member_money_low:g("member_money_low").value,
							non_arrival:g("non_arrival").value,
							arrears:g("arrears").value,
							//card_expire:g("card_expire").value,
							service_expire:g("service_expire").value,
							time_card:g("time_card").value,
							low_stock:g("low_stock").value,
							is_support:is_support?1:2,
							many_cost:g("many_cost").value,
							many_recharge:g("many_recharge").value,
							is_recommend:is_recommend?1:2,
							many_recommend:g("many_recommend").value,
							member_recommend:member_recommend?1:2,
							recommend_score_percent:g("recommend_score_percent").value||0
						}
					}
					console.log(data);
					ajax(data,function(res){
						console.log("参数修改",res)
						mui.toast(res.msg);
					})
				})
			}
			
			function getsetdetail(){
				var data = {
					url:"/api/set/detail",
					data:{access_token:acctoken()}
				}
				ajax(data,function(res){
					console.log("配置详情",res);
					pid = res.data.id;
					setmainlist(res.data);
				})
			}
			
			function setmainlist(data){
				
				g("init_password").value = data.init_password;	//初始密码
				if(data.round_up == 1){	//四舍五入
					g("round_up").classList.add('mui-active');
				}
				if(data.cross_shop == 1){	//跨店消费
					g("cross_shop").classList.add('mui-active');
				}
				if(data.edit_percent == 1){	//开单修改
			   		g("edit_percent").classList.add('mui-active');
			   	}
				if(data.edit_price == 1){	//收银开单时修改
			   		g("edit_price").classList.add('mui-active');
			   	}
				
				if(data.zero_stock_out == 1){	//0库存出库
			   		g("zero_stock_out").classList.add('mui-active');
			   	}
			  	
			   	g("member_birthday").value = data.member_birthday;	//顾客生日
			   	g("member_money_low").value = data.member_money_low; 	//会员余额
			   	g("non_arrival").value = data.non_arrival;	//久未到店
			   	g("arrears").value = data.arrears;	//顾客欠款
			    //g("card_expire").value = data.card_expire;	//会员卡到期
			    g("service_expire").value = data.service_expire;	//服务项目到期
			    g("time_card").value = data.time_card;	//次卡不足
			    g("low_stock").value = data.low_stock;	//库存不足
			    if(data.is_support == 1){		//消费是否积分
			  		g("is_support").classList.add('mui-active');
			  	}
			    g("many_cost").value = data.many_cost;	//消费多少积一份
			    g("many_recharge").value = data.many_recharge; 	//充值多少积一分
			    if(data.is_recommend == 1){	//推荐会员是否积分
			  		g("is_recommend").classList.add('mui-active');
			  	}
			    g("many_recommend").value = data.many_recommend;	//推荐一名积分多少
			    if(data.member_recommend == 1){	//被推荐人是否积分
			  		g("member_recommend").classList.add('mui-active');
			  	}
			    if(data.percent == 1){
			  		g("percent").classList.add('mui-active');
			  	}
			    g("recommend_score_percent").value = data.recommend_score_percent;
			}
		</script>
	</body>

</html>